if (isDedicated) exitWith{};

waituntil {!(isnull player)};

////////////////////////////////////////////////////////////
// Respawn Handling
////////////////////////////////////////////////////////////

player switchmove "";
player setskill 0;
{player disableAI _x} foreach ["move","anim","target","autotarget"];
player setVariable ["BIS_noCoreConversations", true];
player disableConversation true;
	
player addRating -(rating player);

if (hasInterface) then {
	if (isnil "show_mission_intro" || {show_mission_intro}) then {
		[] execVM "tmf\core\scripts\intro.sqf";
	};

	 waituntil {!isnull (findDisplay 46)};
	(findDisplay 46) displayAddEventHandler ["KeyDown", "_this call mso_core_fnc_keydownHandler"];
	
	// Temporary fix when BIS broke serverCommandAvailable
	// with uiNamespace do {
		// private ["_ctrl","_eh"];
		// disableserialization; 
		// _ctrl = findDisplay 46 ctrlCreate ["RscMapControlEmpty", -1];
		// _ctrl ctrlsetposition [0,0,0,0];
		// _ctrl ctrlCommit 0;
		// uiNameSpace setVariable ["TMF_HIDDEN_MAP",_ctrl];
		// _eh = _ctrl ctrlAddEventHandler [
			// "Draw",
			// {
				// with uiNamespace do {
					// missionNameSpace setVariable ["isAdmin", servercommandavailable "#logout"]; 
				// }
			// }
		// ];
		// uiNameSpace setVariable ["TMF_HIDDEN_MAP_EH",_eh];
	// };

	if (!isNil "mp_rights_fnc_isMember") then {
		if (player call mp_rights_fnc_isMember) then {
			[player,"TeamInsigna"] call BIS_fnc_setUnitInsignia;
		};
	} else {
		[player,"TeamInsigna"] call BIS_fnc_setUnitInsignia;
	};
};